%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/person-log-entries"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[33]<br />ᐳ: Access[9], Access[10], Object[11]<br />2: PgSelect[8]<br />ᐳ: Access[20], Access[34]<br />3: Connection[12]<br />4: ConnectionItems[14]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 20, 14, 34<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 20, 34<br /><br />ROOT __Item{3}ᐸ14ᐳ[17]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 17, 34, 18, 21<br /><br />ROOT Edge{3}[18]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 19, 36<br /><br />ROOT PgSelectSingle{4}ᐸpeopleᐳ[19]"):::bucket
    Bucket6("Bucket 6 (listItem)<br /><br />ROOT __Item{6}ᐸ28ᐳ[29]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸpeopleᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply33["PgSelectInlineApply[33∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply33 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    ConnectionItems14[["ConnectionItems[14∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems14
    Access20{{"Access[20∈0] ➊<br />ᐸ8.cursorDetailsᐳ"}}:::plan
    PgSelect8 --> Access20
    Access34{{"Access[34∈0] ➊<br />ᐸ8.m.subqueryDetailsFor23ᐳ"}}:::plan
    PgSelect8 --> Access34
    Edge18{{"Edge[18∈3]"}}:::plan
    __Item17[/"__Item[17∈3]<br />ᐸ14ᐳ"\]:::itemplan
    PgCursor21{{"PgCursor[21∈3]"}}:::plan
    __Item17 & PgCursor21 --> Edge18
    __Item17 & Access20 --> PgCursor21
    ConnectionItems14 ==> __Item17
    List35{{"List[35∈4]<br />ᐸ34,17ᐳ"}}:::plan
    Access34 & __Item17 --> List35
    PgSelectSingle19{{"PgSelectSingle[19∈4]<br />ᐸpeopleᐳ"}}:::plan
    __Item17 --> PgSelectSingle19
    Lambda36{{"Lambda[36∈4]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List35 --> Lambda36
    PgClassExpression22{{"PgClassExpression[22∈5]<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    PgSelectSingle19 --> PgClassExpression22
    PgClassExpression27{{"PgClassExpression[27∈5]<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgClassExpression22 o--o PgClassExpression27
    PgSelectRows28[["PgSelectRows[28∈5]"]]:::plan
    Lambda36 --> PgSelectRows28
    __Item29[/"__Item[29∈6]<br />ᐸ28ᐳ"\]:::itemplan
    PgSelectRows28 ==> __Item29
    PgSelectSingle30{{"PgSelectSingle[30∈6]<br />ᐸlog_entriesᐳ"}}:::plan
    __Item29 --> PgSelectSingle30
    PgClassExpression31{{"PgClassExpression[31∈6]<br />ᐸ__log_entries__.”text”ᐳ"}}:::plan
    PgSelectSingle30 --> PgClassExpression31
    PgClassExpression32{{"PgClassExpression[32∈6]<br />ᐸ__log_entries__.”id”ᐳ"}}:::plan
    PgClassExpression31 o--o PgClassExpression32

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,ConnectionItems14,Access20,PgSelectInlineApply33,Access34 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item17,Edge18,PgCursor21 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle19,List35,Lambda36 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression22,PgClassExpression27,PgSelectRows28 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item29,PgSelectSingle30,PgClassExpression31,PgClassExpression32 bucket6

